package com.imooc.coupon.vo;

import com.imooc.coupon.constant.CouponCategory;
import com.imooc.coupon.constant.DistributeTarget;
import com.imooc.coupon.constant.ProductLine;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Locale;

/**
 * 优惠券创建模板请求对象
 *
 * @Author Administrator
 * @Date 2021/10/16 20:53
 * @Version 1.0
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TemplateRequest {
    /* 优惠券名称*/
    private String name;

    /* 优惠券logo*/
    private String logo;

    /* 优惠券描述*/
    private String desc;

    /* 优惠券分类*/
    private String category;

    /* 产品线*/
    private Integer productLine;
    /* 总数*/
    private Integer count;
    /* 创建用户*/
    private Long userId;

    /* 目标用户*/
    private Integer target;

    /* 优惠券规则*/
    private TemplateRule rule;

    /**
     * 校验对象合法性
     */
    public boolean validate() {
        Boolean stringValid = StringUtils.isNotEmpty(name)
                && StringUtils.isNotEmpty(logo)
                && StringUtils.isNotEmpty(desc);
        Boolean enumValid = CouponCategory.of(category) != null
                && ProductLine.of(productLine) != null
                && DistributeTarget.of(target) != null;
        boolean numValid = count > 0 && userId > 0;
        return stringValid && enumValid && numValid;
    }


}
